//
//  ChoiceTableviewCell.m
//  NewNest
//
//  Created by 王阳阳 on 16/3/9.
//  Copyright © 2016年 www.lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "ChoiceTableviewCell.h"
#import <UIImageView+WebCache.h>
@implementation ChoiceTableviewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.img = [[UIImageView alloc] init];
        _img.layer.cornerRadius = 5;
        _img.clipsToBounds = YES;
        // 图片按比例放置
        _img.contentMode = UIViewContentModeScaleAspectFill;
        [self.contentView addSubview:_img];
        
        //标题
        self.titleLabel = [[UILabel alloc] init];
        _titleLabel.numberOfLines = 0;
        [self.contentView addSubview:_titleLabel];
        
        //风格
        self.styleLabel = [[UILabel alloc] init];
        _styleLabel.font = [UIFont systemFontOfSize:14];
        [self.contentView addSubview:_styleLabel];
        
        //面积
        self.squareLabel = [[UILabel alloc] init];
        _squareLabel.font = [UIFont systemFontOfSize:14];
        [self.contentView addSubview:_squareLabel];
        
        //价格
        self.priceLabel = [[UILabel alloc] init];
        _priceLabel.textColor = [UIColor redColor];
        _priceLabel.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:_priceLabel];
    }
    return self;
}
-(void)setModel:(ChoiceModel *)model
{
    _model = model;
    NSMutableArray *arr = model.imageUrl;
    [_img sd_setImageWithURL:[NSURL URLWithString:arr[0]]];
    _titleLabel.text = model.name;
    _styleLabel.text = model.style;
    _squareLabel.text = model.space;
    _priceLabel.text = model.price;
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    self.img.frame = CGRectMake(20, 30, self.contentView.frame.size.width - 40, self.frame.size.height - 75);
    self.titleLabel.frame = CGRectMake( 20, _img.frame.origin.y + _img.frame.size.height + 5 , _img.frame.size.width - 40, 30);
    self.styleLabel.frame = CGRectMake(20, _titleLabel.frame.origin.y + _titleLabel.frame.size.height + 5, self.contentView.frame.size.width / 4, 20);
    self.squareLabel.frame = CGRectMake(30 + _styleLabel.frame.size.width, _styleLabel.frame.origin.y, _styleLabel.frame.size.width, _styleLabel.frame.size.height);
    self.priceLabel.frame = CGRectMake(self.contentView.frame.size.width - 80, _titleLabel.frame.origin.y , 70, _titleLabel.frame.size.height + _styleLabel.frame.size.height);
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
